Skip to content

fix(models): preserve specification extensions in OpenApiPaths and OpenApiResponses copy constructors - #3162

Merged
Vincent Biret (baywet) merged 8 commits into
microsoft:mainfrom
hardikkaurani:fix/preserve-extensions-in-paths-and-responses-copy-constructors
Nov 6, 2026
Merged

Vincent Biret (baywet) merged 8 commits into
microsoft:mainfrom
hardikkaurani:fix/preserve-extensions-in-paths-and-responses-copy-constructors

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Pull Request

Description

This pull request ensures that specification extensions (Extensions) are preserved when copying OpenApiPaths and OpenApiResponses instances via their copy constructors.

Previously, OpenApiPaths(OpenApiPaths paths) and OpenApiResponses(OpenApiResponses openApiResponses) called base(dictionary: ...) without forwarding the existing instance's Extensions. Because the extensions parameter defaults to null, OpenApiExtensibleDictionary initialized Extensions = [], dropping any specification extensions configured on Paths or Responses.

This also caused OpenApiDocument(OpenApiDocument document) and OpenApiOperation(OpenApiOperation operation) to lose any Paths.Extensions and Responses.Extensions during document or operation cloning.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Related Issue(s)

None.

Changes Made

  • Updated OpenApiPaths(OpenApiPaths paths) to pass extensions: paths?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(paths.Extensions) : null to the base constructor.
  • Updated OpenApiResponses(OpenApiResponses openApiResponses) to pass extensions: openApiResponses?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(openApiResponses.Extensions) : null to the base constructor.
  • Updated XML documentation on both copy constructors to clarify that specification extensions are copied into a new dictionary.
  • Added comprehensive unit tests in OpenApiPathsTests and OpenApiResponsesTests covering extensions preservation, dictionary mutation isolation, null parameter handling, and empty extensions handling.
  • Added regression tests in OpenApiDocumentTests and OpenApiOperationTests verifying that cloning an OpenApiDocument preserves Paths.Extensions and cloning an OpenApiOperation preserves Responses.Extensions.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Local verification:

  • dotnet test test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj -> 1322 passed, 0 failed.
  • dotnet test test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj -> 637 passed, 0 failed.

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Versions applicability

  • My change applies to the version 1.X of the library, if so PR link:
  • My change applies to the version 2.X of the library, if so PR link:
  • My change applies to the version 3.X of the library, if so PR link:
  • I have evaluated the applicability of my change against the other versions above.

See the contributing guidelines for more information about how patches are applied across multiple versions.

Additional Notes

Preserves full backwards compatibility and public API analyzer surface without any breaking changes.

Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…ions

Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
… extensions

Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…tensions

Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…onses extensions

Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…ths and Responses copy constructors

Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…ponses copy constructors

Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
@hardikkaurani
Hardik K (hardikkaurani) requested a review from a team as a code owner November 5, 2026 18:25
Copilot AI balanced review requested due to automatic review settings November 5, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@hardikkaurani

Hardik K (hardikkaurani) commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet),

While working with the model copy constructors, I noticed that OpenApiPaths and OpenApiResponses, both deriving from OpenApiExtensibleDictionary<T>, invoked base(dictionary: ...) without passing the existing instance's Extensions.

Since the extensions parameter defaults to null, any specification extensions attached to Paths or Responses were silently dropped during cloning. This also affected copies of parent OpenApiDocument and OpenApiOperation instances.

This PR updates both copy constructors to pass a shallow copy of Extensions to the base class, adds unit and regression tests covering the affected models, and updates the corresponding XML documentation.

Whenever you have a moment, I'd appreciate your review. Thank you!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the changes preserving extensions when copying OpenApiPaths and OpenApiResponses.

No open issues 🎉

Review effort: Balanced

@baywet
Vincent Biret (baywet) merged commit a68f8be into microsoft:main Nov 6, 2026
9 checks passed
Vincent Biret (baywet) added a commit that referenced this pull request Nov 6, 2026
…enApiResponses copy constructors (#3162) (#3163)

* fix(models): preserve extensions in OpenApiPaths copy constructor



* test(models): add unit tests for OpenApiPaths copy constructor extensions



* test(models): verify OpenApiDocument copy constructor preserves Paths extensions



* fix(models): preserve extensions in OpenApiResponses copy constructor



* test(models): add unit tests for OpenApiResponses copy constructor extensions



* test(models): verify OpenApiOperation copy constructor preserves Responses extensions



* test(models): add edge case tests for null and empty extensions in Paths and Responses copy constructors



* docs(models): update XML documentation on OpenApiPaths and OpenApiResponses copy constructors



---------

Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
Co-authored-by: Hardik K <hardikkaurani1@gmail.com>
This was referenced Nov 30, 2026
Sebastian Paul Boghiu (ThorSPB) pushed a commit to CampusPulse-ro/api that referenced this pull request Nov 30, 2026
Updated
[coverlet.collector](https://github.com/coverlet-coverage/coverlet) from
10.1.0 to 10.1.1.

<details>
<summary>Release notes</summary>

_Sourced from [coverlet.collector's
releases](https://github.com/coverlet-coverage/coverlet/releases)._

## 10.1.1

### Improvements

- Add `IsReachable` to branch points, computed from the method's
control-flow graph, and exclude unreachable branches from
branch-coverage totals and from branch details in Cobertura, LCOV and
OpenCover reports
[#​2056](coverlet-coverage/coverlet#2056) by
@​pcshrosbree
- coverlet.MTP: Narrow Dynamic Exclude Filters for Loaded Assemblies
[#​2069](coverlet-coverage/coverlet#2069)

### Fixed

- Fix Regression Prevent invalid IL from branch trampolines
[#​2067](coverlet-coverage/coverlet#2067)
- Fix Regression coverlet.MTP does not instrument local functions
[#​2046](coverlet-coverage/coverlet#2046)

## Maintenance

- Update NuGet package versions
[#​2050](coverlet-coverage/coverlet#2050)

[Diff between 10.1.0 and
10.1.1](coverlet-coverage/coverlet@v10.1.0...v10.1.1)

Commits viewable in [compare
view](coverlet-coverage/coverlet@v10.1.0...v10.1.1).
</details>

Updated
[Microsoft.AspNetCore.Authentication.JwtBearer](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.AspNetCore.Authentication.JwtBearer's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.AspNetCore.Mvc.Testing](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.AspNetCore.Mvc.Testing's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated [Microsoft.AspNetCore.OpenApi](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.AspNetCore.OpenApi's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Pinned [Microsoft.EntityFrameworkCore](https://github.com/dotnet/dotnet)
at 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.EntityFrameworkCore's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.EntityFrameworkCore.Design](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.EntityFrameworkCore.Design's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.EntityFrameworkCore.Relational](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.EntityFrameworkCore.Relational's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.Extensions.ApiDescription.Server](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.Extensions.ApiDescription.Server's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest)
from 18.11.0 to 18.12.0.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.NET.Test.Sdk's
releases](https://github.com/microsoft/vstest/releases)._

## 18.12.0

## Security fix

This release includes the fix for CVE-2026-105544, an elevation of
privilege vulnerability in the VSTest artifact post-processor. The
post-processor could consume a forged `executionComplete.json` written
by another local user, and then run attacker-controlled output handling.

Affected: `Microsoft.TestPlatform.CLI` 18.11.0 and earlier. Every
version from 18.11.1 on is fixed, including 18.12.0.

`Microsoft.TestPlatform.CLI` is the VSTest build that we ship into the
.NET SDK. The recommended way to get this fix is to update your .NET SDK
to the latest patched version, see the advisory for the SDK versions.

The fix is also released in the `Microsoft.TestPlatform.CLI` package,
for completeness. That package is rarely used directly. It is not a
dependency of `Microsoft.NET.Test.Sdk` or `Microsoft.TestPlatform`, so
those packages do not bring it in.

Details: microsoft/vstest#16654 and
dotnet/announcements#517

Using custom Docker images or Nano Server? See
microsoft/vstest#16652

## What's Changed
* Fix TestCaseStart/Stop events dropped for data-driven tests with
shared TestCase.Id by @​nohwnd in
microsoft/vstest#16033
* Stop the discovery manager factory from shadowing discoveryCriteria by
@​nohwnd in microsoft/vstest#16391
* Gate the HTTP link checker on a fingerprint of the broken links by
@​nohwnd in microsoft/vstest#16413
* Quote boolean conditions in shipped Microsoft.TestPlatform.targets by
@​nohwnd in microsoft/vstest#16404
* Obsolete API hygiene: the compatibility-safe changes by @​azat-msft in
microsoft/vstest#16420
* Add xxHash128 test ids, available but not default by @​azat-msft in
microsoft/vstest#16378
* Isolate attachment manager test temporary files by @​mmitche in
microsoft/vstest#16463
* Test ids report logger by @​azat-msft in
microsoft/vstest#16443
* Isolate code coverage files in published output by @​azat-msft in
microsoft/vstest#16483
* Preserve OutputType for Android test projects by @​jonathanpeppers in
microsoft/vstest#16496
* Fix dotnet host resolution under proot (ARM64/Termux) by @​azat-msft
in microsoft/vstest#16462
* Mark the xxHash128 test id API as experimental by @​azat-msft in
microsoft/vstest#16465
* Ship Microsoft.Diagnostics.NETCore.Client in Microsoft.TestPlatform
and Portable packages by @​nohwnd in
microsoft/vstest#16633
* Fix localized resource paths in CLI source-build/non-Windows packages
by @​nohwnd in microsoft/vstest#16644


**Full Changelog**:
microsoft/vstest@v18.11.0...v18.12.0



## 18.11.1

## Security fix

This release fixes CVE-2026-105544, an elevation of privilege
vulnerability in the VSTest artifact post-processor. The post-processor
could consume a forged `executionComplete.json` written by another local
user, and then run attacker-controlled output handling.

Affected: `Microsoft.TestPlatform.CLI` 18.11.0.
Fixed in: `Microsoft.TestPlatform.CLI` 18.11.1.

`Microsoft.TestPlatform.CLI` is the VSTest build that we ship into the
.NET SDK. The recommended way to get this fix is to update your .NET SDK
to the latest patched version, see the advisory for the SDK versions.

The fix is also released in the `Microsoft.TestPlatform.CLI` package,
for completeness. That package is rarely used directly. It is not a
dependency of `Microsoft.NET.Test.Sdk` or `Microsoft.TestPlatform`, so
those packages do not bring it in.

Details: microsoft/vstest#16654 and
dotnet/announcements#517

Using custom Docker images or Nano Server? See
microsoft/vstest#16652

## What's Changed
* Security fix for CVE-2026-105544, see
microsoft/vstest#16654
* Ship Microsoft.Diagnostics.NETCore.Client in Microsoft.TestPlatform
and Portable packages by @​nohwnd in
microsoft/vstest#16632
* Fix localized resource paths in CLI source-build packages by @​nohwnd
in microsoft/vstest#16643

**Full Changelog**:
microsoft/vstest@v18.11.0...v18.11.1

Commits viewable in [compare
view](microsoft/vstest@v18.11.0...v18.12.0).
</details>

Updated [Microsoft.OpenApi](https://github.com/Microsoft/OpenAPI.NET)
from 2.13.0 to 2.13.1.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.OpenApi's
releases](https://github.com/Microsoft/OpenAPI.NET/releases)._

## 2.13.1

##
[2.13.1](microsoft/OpenAPI.NET@v2.13.0...v2.13.1)
(2026-11-16)


### Bug Fixes

* **models:** preserve specification extensions in OpenApiPaths and
OpenApiResponses copy constructors
([#​3162](microsoft/OpenAPI.NET#3162))
([#​3163](microsoft/OpenAPI.NET#3163))
([3301ba7](microsoft/OpenAPI.NET@3301ba7))
* **models:** preserve tag collection types and comparers in copy
constructors
([#​3141](microsoft/OpenAPI.NET#3141))
([#​3145](microsoft/OpenAPI.NET#3145))
([aa5e2b5](microsoft/OpenAPI.NET@aa5e2b5))
* **models:** preserve tag collection types and comparers in
OpenApiDocument copy constructor
([aa5e2b5](microsoft/OpenAPI.NET@aa5e2b5))
* **reader:** backport external reference file loading to v2
([#​3174](microsoft/OpenAPI.NET#3174))
([cb3003a](microsoft/OpenAPI.NET@cb3003a))
* **reader:** backport external reference loading to v2
([cb3003a](microsoft/OpenAPI.NET@cb3003a))
* Support custom tag ordering and null assignment in
OpenApiOperation.Tags
([#​3128](microsoft/OpenAPI.NET#3128))
([#​3133](microsoft/OpenAPI.NET#3133))
([295c89c](microsoft/OpenAPI.NET@295c89c))
* support reinitializing OpenApiOperation.Tags to null and custom
comparers
([#​3116](microsoft/OpenAPI.NET#3116))
([#​3142](microsoft/OpenAPI.NET#3142))
([9cfcdd2](microsoft/OpenAPI.NET@9cfcdd2))
* **v2:** map OpenAPI 2.0 response schema type file to binary format
([#​3150](microsoft/OpenAPI.NET#3150))
([#​3151](microsoft/OpenAPI.NET#3151))
([4cf52e1](microsoft/OpenAPI.NET@4cf52e1))
* **v3:** retain full JSON pointer path on OpenAPI 3.0 schema references
([#​3155](microsoft/OpenAPI.NET#3155))
([#​3170](microsoft/OpenAPI.NET#3170))
([16969bc](microsoft/OpenAPI.NET@16969bc))

Commits viewable in [compare
view](microsoft/OpenAPI.NET@v2.13.0...v2.13.1).
</details>

Pinned
[Npgsql.EntityFrameworkCore.PostgreSQL](https://github.com/npgsql/efcore.pg)
at 10.0.4.

<details>
<summary>Release notes</summary>

_Sourced from [Npgsql.EntityFrameworkCore.PostgreSQL's
releases](https://github.com/npgsql/efcore.pg/releases)._

## 10.0.4

[Milestone
issue](https://github.com/npgsql/efcore.pg/milestone/79?closed=1)

## What's Changed
* [10.0] Backport regex operand parentheses fix by @​roji in
npgsql/efcore.pg#3928
* [10.0] Remove unused SSL setup from Windows CI by @​roji in
npgsql/efcore.pg#3931
* [10.0] Backport unnest type mapping inference fix by @​roji in
npgsql/efcore.pg#3945
* [10.0] Truncate sub-microsecond ticks when formatting TimeSpan as
interval by @​roji in npgsql/efcore.pg#3947
* [10.0] Preserve row value type mappings when rewriting expressions by
@​roji in npgsql/efcore.pg#3954
* [10.0] Fix Last() on primitive collections returning the first array
element by @​roji in npgsql/efcore.pg#3956
* [10.0] Configure row value regression tuple mapping locally by @​roji
in npgsql/efcore.pg#3960
* [10.0] Update EF Core and other dependencies by @​roji in
npgsql/efcore.pg#3963
* [10.0] Fix collection conversion with nullable element converters
(#​3965) by @​roji in npgsql/efcore.pg#3967
* [10.0] Fix Contains on an object collection over a value-converted
column (#​3961) by @​roji in
npgsql/efcore.pg#3970
* [10.0] Fix tsvector metadata cast for IReadOnlyList by @​roji in
npgsql/efcore.pg#3986
* [10.0] Fix explicit column types for owned JSON collections by @​roji
in npgsql/efcore.pg#3989
* [10.0] Prevent PadLeft/PadRight from truncating shorter target widths
by @​roji in npgsql/efcore.pg#3993
* [10.0] Fix array type inference for mixed collection types by @​roji
in npgsql/efcore.pg#3996
* [10.0] Fix null checks on unbounded NodaTime Interval bounds by @​roji
in npgsql/efcore.pg#4002
* [10.0] Backport fix for null propagation in date/time intervals by
@​roji in npgsql/efcore.pg#4015
* [10.0] Support System.Text.Json serialization of LTree by @​roji in
npgsql/efcore.pg#4010
* [10.0] Preserve array element converters with explicit column types by
@​roji in npgsql/efcore.pg#4011
* [10.0] Fix repeated seed-data updates for list properties by @​roji in
npgsql/efcore.pg#4029
* [10.0] Fix BCE NodaTime SQL literal formatting by @​roji in
npgsql/efcore.pg#4027
* [10.0] Preserve inherited HiLo sequences in model snapshots by @​roji
in npgsql/efcore.pg#4032
* [10.0] Fix date/time mapping round-tripping and cloning by @​roji in
npgsql/efcore.pg#4037
* [10.0] Fix Regex.Replace to replace all matches by @​roji in
npgsql/efcore.pg#4041
* [10.0] Restore raw JSON byte array mapping by @​roji in
npgsql/efcore.pg#4044
* [10.0] Translate ToString() on string expressions by @​roji in
npgsql/efcore.pg#4050
* [10.0] Own newly cloned connections by @​roji in
npgsql/efcore.pg#4056
* [10.0] Fix type mapping for derived tsquery parameters by @​roji in
npgsql/efcore.pg#4060
* [10.0] Fix precision-only numeric migration snapshot churn by @​roji
in npgsql/efcore.pg#4070
* [10.0] Fix byte-array projections from JSON collections by @​roji in
npgsql/efcore.pg#4073
* [10.0] Fix tsvector columns over JSON-mapped navigations/complex
properties by @​roji in npgsql/efcore.pg#4076
* [10.0] Fix hstore SQL literal generation for null and escaped values
by @​roji in npgsql/efcore.pg#4106
* [10.0] Fix TimeOnly.IsBetween for midnight-spanning ranges by @​roji
in npgsql/efcore.pg#4131
* [10.0] Parenthesize the item of ANY/ALL when its precedence requires
it by @​roji in npgsql/efcore.pg#4132
* [10.0] Format storage parameter values with the invariant culture by
@​roji in npgsql/efcore.pg#4133


**Full Changelog**:
npgsql/efcore.pg@v10.0.3...v10.0.4

Commits viewable in [compare
view](npgsql/efcore.pg@v10.0.3...v10.0.4).
</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants